#include <iostream>
using namespace std;
int main(){
    string a;
    cin >> a;
    for (size_t i=0;i<a.length();i++){
        cout << 9 - (a[i] - '0');
    }
    cout << endl;
}
